package com.mew.lobby.handler.invite;

import com.mew.common.entity.user.User;
import com.mew.common.exception.ResponseCode;
import com.mew.common.rest.StringMessage;
import com.mew.common.rest.bo.MewSession;
import com.mew.common.rest.user.UserDetailedInfoResponseMessage;
import com.mew.lobby.annotation.LobbyHandler;
import com.mew.lobby.net.LobbyHandlerMapCmdType;
import com.mew.lobby.net.MewHandler;
import com.mew.lobby.provide.InviteFeignService;
import com.mew.lobby.provide.UserFeignService;
import com.zebra.remoting.protocol.ZebraCommand;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 绑定推荐人
 * @author dylin
 * @create 2021/3/30
 */
@Service
@Slf4j
@LobbyHandler(LobbyHandlerMapCmdType.BindInviter)
public class BindInviterHandler implements MewHandler<StringMessage> {
    @Autowired
    private InviteFeignService inviteFeignService;

    @Override
    public void handle(ZebraCommand<StringMessage> zebraCommand, MewSession session) {
        String inv = zebraCommand.getRequest().getS();
        zebraCommand.sendFailureCode(inviteFeignService.bindInviter(session.uid,inv));
    }
}
